import java.util.ArrayList;


public class Piece
{
   private int      player;
   private Position position;
   
   public Piece(Position a)
   {
      position = a;
   }
   public Piece(Position a, int player)
   {
      position      = a;
      this.player   = player;
   }
   public int getPlayer()
   {
      return player;
   }
   public Position getPosition()
   {
      return position;
   }
   public void setPosition(Position newpos)
   {
      position = newpos;
   }
   public boolean isSameTeam(Piece p)
   {
      return p.getPlayer() == this.player;
   }
   public ArrayList<Position> getMoves(Board board)
   {
      ArrayList<Position> moves = new ArrayList<Position>();
      
      Position topright         = new Position(position.row + 1, position.col - 1);
      Position topleft          = new Position(position.row - 1, position.col - 1);
      
      System.out.println("current position: x: "+position.row+" y: "+position.col);
      //If there is nothing there, the position is available
      Piece p = board.getPiece(topright);
      if(p == null)
      {
         moves.add(topright);
      }
      //else check the topright's corner
      else if(!isSameTeam(p))
      {
         Position next = new Position(topright.row + 1, topright.col - 1);
         moves.add(next);        
      }
      
      p = board.getPiece(topleft);
      if(p == null)
      {
         moves.add(topleft);
      }
      else if(!isSameTeam(p))
      {
         Position next = new Position(topleft.row - 1, topleft.col - 1);         
         moves.add(next);
      }
      
      for (Position position : moves)
      {
         System.out.println("x: "+position.row + " y: "+position.col);
      }
      
      return moves;
   }
   
}
